<template>
  <div class="member-home">
    <!-- 概览 -->
    <HomeOverview />
    <!-- /概览 -->

    <!-- 收藏 -->
    <HomePanel title="我的收藏">
      <GoodsItem v-for="item in collectGoods" :key="item.id" :goods="item" />
    </HomePanel>
    <!-- /收藏 -->

    <!-- 足迹 -->
    <HomePanel title="我的足迹">
      <GoodsItem v-for="item in browseGoods" :key="item.id" :goods="item" />
    </HomePanel>
    <!-- /足迹 -->

    <!-- 猜你喜欢 -->
    <GoodsRelevant />
    <!-- /猜你喜欢 -->
  </div>
</template>

<script>
import HomeOverview from './components/home-overview'
import HomePanel from './components/home-panel'
import GoodsRelevant from '@/views/goods/components/goods-relevant'
import GoodsItem from '@/views/category/components/goods-item'
import { findCollect, findBrowseHistory } from '@/api/member'
import { ref } from 'vue'

export default {
  name: 'MemberHome',
  components: {
    HomeOverview,
    HomePanel,
    GoodsRelevant,
    GoodsItem
  },
  setup () {
    // 调用我的收藏模拟接口
    const collectGoods = ref([])
    findCollect({
      page: 1,
      pageSize: 4
    }).then(data => {
      collectGoods.value = data.result.items
    })

    // 调用我的足迹模拟接口
    const browseGoods = ref([])
    findBrowseHistory({
      page: 1,
      pageSize: 4
    }).then(data => {
      browseGoods.value = data.result.items
    })
    return { collectGoods, browseGoods }
  }
}
</script>

<style scoped lang="less">
:deep(.xtx-carousel) .carousel-btn.prev {
  left: 5px;
}
:deep(.xtx-carousel) .carousel-btn.next {
  right: 5px;
}
</style>
